@{
    ViewBag.Title = "用户管理";
    
}
<script>
    $(function () {
        InitialPage();
        GetGrid();
    });
    //初始化页面
    function InitialPage() {
        //resize重设(表格、树形)宽高
        $(window).resize(function (e) {
            window.setTimeout(function () {
                $('#gridTable').setGridWidth(($('.gridPanel').width()));
                $("#gridTable").setGridHeight($(window).height() - 136.5);
            }, 200);
            e.stopPropagation();
        });
        $('div.grid-filter header').click(function () {
            $('i.toggle-filter', this).toggleClass('fa-chevron-down fa-chevron-up');
            var $hf = $('input', this).first();
            if ($hf.val() != 'true') {
                $hf.val('true');
            } else {
                $hf.val('false');
            }
            $(this).siblings('div').slideToggle();
        });
    }
    //加载表格
    function GetGrid() {
        var selectedRowIndex = 0;
        var $gridTable = $('#gridTable');
        $gridTable.jqGrid({
            url: "/User/GetPageListJson",
            datatype: "json",
            height: $(window).height() - 136.5,
            autowidth: true,
            colModel: [
                { label: '主键', name: 'Id', hidden: true },
                { label: '账户', name: 'Email', index: 'Email', width: 100, align: 'left' },
                { label: '姓名', name: 'FullName', index: 'FullName', width: 100, align: 'left' },
                {
                    label: "状态", name: "IsDeleted", index: "IsDeleted", width: 50, align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        if (cellvalue == 1) {
                            return '<span onclick=\"btn_disabled(\'' + rowObject.UserId + '\')\" class=\"label label-success\" style=\"cursor: pointer;\">正常</span>';
                        } else if (cellvalue == 0) {
                            return '<span onclick=\"btn_enabled(\'' + rowObject.UserId + '\')\" class=\"label label-default\" style=\"cursor: pointer;\">禁用</span>';
                        }
                    }
                } 
            ],
            viewrecords: true,
            rowNum: 30,
            rowList: [30, 50, 100],
            pager: "#gridPager",
            sortname: 'Email asc,CreatedDate desc',
            rownumbers: true,
            shrinkToFit: false,
            gridview: true,
            onSelectRow: function () {
                selectedRowIndex = $("#" + this.id).getGridParam('selrow');
            },
            gridComplete: function () {
                $("#" + this.id).setSelection(selectedRowIndex, false);
            }
        });
        $gridTable.authorizeColModel()
        //查询条件
        $("#queryCondition .dropdown-menu li").click(function () {
            var text = $(this).find('a').html();
            var value = $(this).find('a').attr('data-value');
            $("#queryCondition .dropdown-text").html(text).attr('data-value', value)
        });
        //查询事件
        $("#btn_Search").click(function () {
            var queryJson = {
                condition: $("#queryCondition").find('.dropdown-text').attr('data-value'),
                keyword: $("#txt_Keyword").val()
            }
            $gridTable.jqGrid('setGridParam', {
                postData: { queryJson: JSON.stringify(queryJson) }, page: 1
            }).trigger('reloadGrid');
        });
        //查询回车
        $('#txt_Keyword').bind('keypress', function (event) {
            if (event.keyCode == "13") {
                $('#btn_Search').trigger("click");
            }
        });
    }
    //新增
    function btn_add() {
        dialogOpen({
            id: "Form",
            title: '添加用户',
            url: '/User/Form',
            width: "750px",
            height: "550px",
            callBack: function (iframeId) {
                top.frames[iframeId].AcceptClick();
            }
        });
    };
    //编辑
    function btn_edit() {
        var keyValue = $("#gridTable").jqGridRowValue("UserId");
        if (checkedRow(keyValue)) {
            dialogOpen({
                id: "Form",
                title: '修改用户',
                url: '/User/Form?keyValue=' + keyValue,
                width: "750px",
                height: "550px",
                callBack: function (iframeId) {
                    top.frames[iframeId].AcceptClick();
                }
            });
        }
    }
    //删除
    function btn_delete() {
        var keyValue = $("#gridTable").jqGridRowValue("UserId");
        if (keyValue) {
            $.RemoveForm({
                url: "/User/RemoveForm",
                param: { keyValue: keyValue },
                success: function (data) {
                    $("#gridTable").trigger("reloadGrid");
                }
            })
        } else {
            dialogMsg('请选择需要删除的用户！', 0);
        }
    }
    //重置密码
    function btn_revisepassword() {
        var keyValue = $("#gridTable").jqGridRowValue("UserId");
        var Account = $("#gridTable").jqGridRowValue("Account");
        var RealName = $("#gridTable").jqGridRowValue("RealName");
        if (checkedRow(keyValue)) {
            dialogOpen({
                id: "RevisePassword",
                title: '重置密码',
                url: '/User/RevisePassword?keyValue=' + keyValue + "&Account=" + escape(Account) + '&RealName=' + escape(RealName),
                width: "500px",
                height: "260px",
                callBack: function (iframeId) {
                    top.frames[iframeId].AcceptClick();
                }
            });
        }
    }
 
</script>
@*<div class="titlePanel">
        <div class="title-search">
            <table>
                <tr>
                    <td>
                        <div id="queryCondition" class="btn-group">
                            <a class="btn btn-default dropdown-text" data-toggle="dropdown">选择条件</a>
                            <a class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></a>
                            <ul class="dropdown-menu">
                                <li><a data-value="Account">账户</a></li>
                                <li><a data-value="RealName">姓名</a></li>
                                <li><a data-value="Mobile">手机</a></li>
                            </ul>
                        </div>
                    </td>
                    <td style="padding-left: 2px;">
                        <input id="txt_Keyword" type="text" class="form-control" placeholder="请输入要查询关键字" style="width: 200px;" />
                    </td>
                    <td style="padding-left: 5px;">
                        <a id="btn_Search" class="btn btn-primary"><i class="fa fa-search"></i>&nbsp;查询</a>
                    </td>
                </tr>
            </table>
        </div>
        <div class="toolbar">
            <div class="btn-group">
                <a id="lr-replace" class="btn btn-default" onclick="reload();"><i class="fa fa-refresh"></i>&nbsp;刷新</a>
                <a id="lr-add" class="btn btn-default" onclick="btn_add()"><i class="fa fa-plus"></i>&nbsp;新增</a>
                <a id="lr-edit" class="btn btn-default" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>&nbsp;编辑</a>
                <a id="lr-delete" class="btn btn-default" onclick="btn_delete()"><i class="fa fa-trash-o"></i>&nbsp;删除</a>
                <a id="lr-revisepassword" class="btn btn-default" onclick="btn_revisepassword()"><i class="fa fa-key"></i>&nbsp;重置密码</a>
                <a id="lr-more" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                    <i class="fa fa-reorder"></i>&nbsp;更多<span class="caret"></span>
                </a>
                <ul class="dropdown-menu pull-right">
                    <li id="lr-export"><a onclick="btn_export()"><i></i>&nbsp;导出Excel</a></li>
                    <li id="lr-disabled"><a onclick="btn_disabled()"><i></i>&nbsp;禁用账户</a></li>
                    <li id="lr-enabled"><a onclick="btn_enabled()"><i></i>&nbsp;启用账户</a></li>
                </ul>
            </div>
            <div class="btn-group">
                <a id="lr-authorize" class="btn btn-default" onclick="btn_authorize()"><i class="fa fa-gavel"></i>&nbsp;用户权限</a>
                <a id="lr-appfilter" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                    <i class="fa fa-filter"></i>&nbsp;访问过滤<span class="caret"></span>
                </a>
                <ul class="dropdown-menu pull-right">
                    <li id="lr-ipfilter"><a onclick="btn_ipfilter()"><i></i>&nbsp;IP过滤</a></li>
                    <li id="lr-timefilter"><a onclick="btn_timefilter()"><i></i>&nbsp;时段过滤</a></li>
                </ul>
            </div>
            <script>$('.toolbar').authorizeButton()</script>
        </div>
    </div>*@

<section id="page-title">
    <h1 class="title">
        <div class="page-icon">
            <i class="fa fa-users"></i>
        </div> 用户管理
    </h1>
    <ul class="breadcrumb">
        <li><a href="/User"><i class="fa fa-home"></i> 首页</a></li>
        <li class="active">用户</li>
    </ul>

</section>
<section id="page-content">
    <!-- Ajax Error -->
    <div class="alert alert-danger ajax-error" style="display:none">
        <p><strong>错误</strong></p>
        <span class="ajax-error-message"></span>
    </div>
    <div class="row">
        <div class="col-md-12">
            <div id="zone-feature" class="zone-instance can-configure">
                <div class="zone-configuration config-bar">
                    <a class="zoneinstance-config" href="#"><i class="fa fa-arrow-circle-right"></i></a>
                    <div class="zone-configuration-bar">
                        <span>特性</span>
                        <a id="aBlockConfig-Feature" class="zone-blocks" height="500px" href="javascript: SF.controls.modal.show($(this), '/ZoneBlocks/95/Feature?t=Zone Blocks&amp;pb=&amp;sb=Done')" title="Zone Blocks" zone="Feature">
                            <i class="fa fa-th-large"></i>
                        </a>
                    </div>
                </div>
                <div class="zone-content">
                    <div class="block-content">
                        <div class="block-configuration config-bar">
                            <a href="#"><i class="fa fa-arrow-circle-right"></i></a>
                            <div class="block-configuration-bar">
                                <span>列表</span>
                                <a class="properties" height="500px" href="javascript: SF.controls.modal.show($(this), '/BlockProperties/175?t=Block Properties')" title="Block Properties"><i class="fa fa-cog"></i></a><a id="ctl00_main_ctl23_ctl01_aSecureBlock" class="security" height="500px" href="javascript: SF.controls.modal.show($(this), '/Secure/9/175?t=Block Security&amp;pb=&amp;sb=Done')" title="Block Security"><i class="fa fa-lock"></i></a><a class="block-move block-move" href="175" data-zone="Main" data-zone-location="Page" title="Move Block"><i class="fa fa-external-link"></i></a>
                                <div class="delete block-delete disabled js-disabled">
                                    <i class="fa fa-times-circle-o"></i>
                                </div>
                            </div>
                        </div>
                        <div class="panel panel-block">
                            <div class="panel-heading">
                                <h1 class="panel-title"><i class="fa fa-exchange"></i> Route List</h1>
                                <div class="grid-actions pull-right">
                                    <a id="gridActions_lbAdd" accesskey="n" title="新增" class="btn-add btn btn-default btn-sm" href="/Route/Edit"><i class="fa fa-plus-circle"></i></a>
                                    <a id="gridActions_lbExcelExport" title="导出" class="btn-excelexport btn btn-default btn-sm"><i class="fa fa-table"></i></a>

                                </div>
                            </div>
                            <div class="panel-body">
                                <div class="grid grid-panel">
                                    <div class="grid-filter">
                                        <header>
                                            <h3>
                                                筛选选择
                                            </h3>
                                            <input type="hidden" id="rFilter_hfVisible" /><i class="fa fa-chevron-down toggle-filter"></i>
                                        </header>
                                        <div class="grid-filter-overview">

                                        </div>
                                        <div class="grid-filter-entry" style="display:none;">
                                            <fieldset>
                                                <h4>筛选选择</h4>
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group sf-text-box ">
                                                            <label class="control-label" for="Account">账户</label>
                                                            <div class="control-wrapper">
                                                                <input name="Account" type="text" id="Account" class="form-control" />
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-4">
                                                        <div class="form-group sf-text-box ">
                                                            <label class="control-label" for="RealName">姓名</label>
                                                            <div class="control-wrapper">
                                                                <input name="RealName" type="text" id="RealName" class="form-control" />
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-4">
                                                        <div class="form-group sf-text-box ">
                                                            <label class="control-label" for="Mobile">手机</label>
                                                            <div class="control-wrapper">
                                                                <input name="Mobile" type="text" id="Mobile" class="form-control" />
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </fieldset>
                                            <a id="btn_Search" title="Apply Filter" class="filter btn btn-action btn-xs">查询</a>
                                        </div>
                                    </div>
                                    <div class="table-responsive">
                                        <div class="gridPanel">
                                            <table id="gridTable"></table>
                                            <div id="gridPager"></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>